﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace MyCode.Project.Infrastructure.Utils
{
    /// <summary>
    /// 验证工具
    /// </summary>
    public class ValidUtil
    {
        /// <summary>
        /// 验证手机号是否正确
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public static bool IsMobile(string mobile)
        {
            if (string.IsNullOrEmpty( mobile) || mobile.Length != 11)
            {
                return false;
            }
            Regex rx = new Regex(@"\d{11}");
            //Regex rx = new Regex(@"^0{0,1}(13[4-9]|15[7-9]|15[0-2]|17[7-8]|18[7-8])[0-9]{8}$");
            if (!rx.IsMatch(mobile)) //不匹配
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
